package com.components.base.view.tiktok

import android.animation.TypeEvaluator
import android.graphics.PointF

class BezierEvaluator(private val pointF1: PointF, private val pointF2: PointF) :
    TypeEvaluator<PointF> {
    override fun evaluate(time: Float, startValue: PointF, endValue: PointF): PointF {
        val timeLeft = 1.0f - time
        val point = PointF()
        point.x =
            timeLeft * timeLeft * timeLeft * startValue.x + 3 * timeLeft * timeLeft * time * pointF1.x + 3 * timeLeft * time * time * pointF2.x + time * time * time * endValue.x
        point.y =
            timeLeft * timeLeft * timeLeft * startValue.y + 3 * timeLeft * timeLeft * time * pointF1.y + 3 * timeLeft * time * time * pointF2.y + time * time * time * endValue.y
        return point
    }
}